VB .NET Windows Apps


1. You are in the process of debugging a large Windows-based application created using Visual Studio .NET development tools. You would like to provide two separate versions of the application and to do so you require the use of one of two different sets of constants based on conditions of the compile. Which two of the following is a correct implementation of the constants?

A. Use resource files and set the application up for localization
B. Uses #Const directives in the code
C. Use an input file to supply values based on conditions of the compile
D. Set the constants up in the conditional compilation declaration space
E. Set the application up as a function with runtime parameters and have the user pass the appropriate data through a console interface

>> !
Answer: B & D

The compilation environment may define conditional constants in the conditional compilation declaration space.
Conditional constant names may always be used without having first been declared.
Localization is used for separate languages and / or cultures, not for conditional compilation.
Setting the application up as a function with runtime parameters and having the user pass the appropriate data through a console interface is a workable solution but not a good one. You are relying on too much user interaction where it really is unnecessary.


2. You are a developer for a scientific research company the uses Visual Studio .NET to generate Windows-based applications. Most of the applications perform a variety of calculations. In the testing process of an application you must ensure that the application properly handles specific ranges of data. You would like to identify the point at which a variable exceeds an upper limit of 64000. You want your application to generate a message in these cases. Which statement would you use?

A. Trace.Assert(TestValue < 64000, "Maximum value surpassed.")
B. Trace.Assert(TestValue >= 64000, "Maximum value surpassed.")
C. Trace.Assert("Maximum value surpassed.", TestValue < 64000)
D. Trace.Assert("Maximum value surpassed.", TestValue >= 64000)

>> !
Answer: A

The assert will print a message if the test condition is false.
Trace.Assert(TestValue >= 64000, "Maximum value surpassed.") will produce the opposite of what is required as the assert will print a message only if the test condition is false.
With Trace.Assert("Maximum value surpassed.", TestValue < 64000), the parameters have been reversed and will not produce the desired results.
With Trace.Assert("Maximum value surpassed.", TestValue >= 64000), the parameters and test condition are both wrong and have been reversed and will not produce the desired results.


3. You are working as a Visual Basic developer for a large manufacturing company ACME Widgets. ACME has recently standardized development on the .NET framework using Visual Studio .NET. The application that you are working on is an upgrade of a previous Visual Basic 6.0 application. It was developed by a colleague that is no longer with the company. The application performs a number of complex calculations to determine the size and shape of the Widgets. All of the variables are defined as double precision numeric variables. Occasionally the application fails during execution. The error received is "Arithmetic operation resulted in an overflow". How can you fix the program?

A. Set Option Strict to Off
B. Set Option Explicit On
C. Set Option Compare On
D. Set Option Strict to On

>> !
Answer: D

The Option Strict statement determines whether conversions and operations on Object are governed by strict or permissive type semantics. It can improve the accuracy of arithmetic conversions and other operations.
Setting this on forces declaration of variables and will not solve any arithmetic issues.
The Option Compare statement controls whether string comparisons are carried out using binary comparisons or text comparisons.
Setting Option Strict to Off would produce the exact opposite of the desired effect.


4. You are working for a large manufacturing organization that uses Visual Basic .NET for application development. You are assigned to a group of developers whom together are developing an application to monitor progress of Widget manufacturing and assembly. You are assigned to create a Windows control that will display custom status bar information. The information will frequently change as the Widgets progress from raw materials to finished product. Many different developers in your company will use the control to display similar information in their applications. It is necessary to have the control always positioned at the bottom of the form in every application. Select the most appropriate answer:

A. DockStyle.Bottom
B. AnchorStyle.Bottom
C. Control.Location New Point(0, 0)
D. Choose Arrange from the Layout menu, and then choose Bottom

>> !
Answer: A & B

DockStyle.Bottom is used to dock the control at the bottom of the form in which it is placed.
The AnchorStyle class specifies how a control anchors to the edges of its container. Not how a control is docked. Control.Location defines the location of a control at run time, not the docking.
Choosing Arrange from the Layout menu and then choosing Bottom will allow you to arrange controls on a form at design time.


5. You are a developer for a government service organization that provides assistance to the public in interacting with several ministries. One of the applications you are working on contains a complex Windows form that needs to provide online help for end users. You need to supply help in the form of a pop-up window for the control that currently has the focus if the user presses the F1 key. You will need to interact with the HelpProvider control passing the text box control and the help text to be displayed. Which method of the HelpProvider control will provide this functionality?

A. SetShowHelp
B. SetHelpString
C. SetHelpKeyword
D. SetHelpNavigator

>> !
Answer: B

To associate a Help string with a control, use the SetHelpString method. The associated text string is displayed in a pop-up window upon pressing the F1 key while the control has focus. Use the SetHelpString method to associate a specific text string with a control.
The SetHelpKeyword provides the help topic.
The SetHelpNavigator method is used to specify the type of help provided.
The SetShowHelp method sets a Boolean true/false indicator as to whether help is displayed for a given control.


6. You are working as one of several developers for an organization that handles transactions for various e-commerce web sites. One of the developers on your team has created a component named BuyIt. You install the BuyIt component to a server but upon execution you receive an error message: "System.Security.Policy.PolicyException: Failed to acquire required permissions." You need to discover what the required permissions are as quickly as possible and the originating developer is out of the office. What can you do?

A. Use the Runtime Debugger (Cordbg.exe) tool on the server.
B. Use the Runtime Debugger (Cordbg.exe) tool on a developer workstation.
C. Run the Permissions View tool (Permview.exe) on the server.
D. Run the Permissions View tool (Permview.exe) on a developer workstation.
E. Wait for the developer to return and acquire the source code. Examine the code to find the required permissions.

>> !
Answer: C

Any developer can use Permview.exe to verify applied permission requests on their code. In this case you do not want to take the time to move to the development machine, ait for the developer to return, acquire the source code and examine the code to find he required permissions. Why wait when you can run the Permissions View tool on the server?

The Runtime Debugger will not allow you to view the Permissions.

Use Permview.exe on the server to view the permissions required.

You want to run the Permissions View tool on the server, not the developer workstation.


7. You are working as a developer for a small accounting firm, Book 'Em. On a form within a Windows-based application you are designing, you wish to have menus that will be created and altered at run time based on user interaction. In some instances there will be no menus while at other times the menus can be considerable. For the purpose of maintaining efficiency you have chosen to not provide any menus at design time. In one section of code you need to initialize the menu with the text "Insert". Under "Insert" you need to place "From File". A MainMenu component is already added to the form. What is required to implement this at runtime? (Choose all that apply)

A.
Dim mnuMenu as New MainMenu()
Me.Menu = mnuMenu
B.
Dim mnuInsertMenu as New MenuItem("&Insert")
Dim mnuFromFileMenu as New MenuItem("&From File")
C.
Dim mnuInsertMenu as New MainMenu("&Insert")
Dim mnuFromFileMenu as New MenuItem("&From File")
D.
mnuMenu.MenuItems.Add(mnuInsertMenu)
mnuInsertMenu.MenuItems.Add(mnuFromFileMenu)
E.
mnuInsertMenu.MenuItems.Add(mnuFromFileMenu)
F.
Dim mnuMenu as New MainMenu("&Insert")
Me.Menu = mnuMenu

>> !
Answer: A, B & D

"Dim mnuInsertMenu as New MenuItem("&Insert")
Dim mnuFromFileMenu as New MenuItem("&From File")"
and
"mnuMenu.MenuItems.Add(mnuInsertMenu)
mnuInsertMenu.MenuItems.Add(mnuFromFileMenu)"

After the creation of an empty MainMenu then Create MenuItem objects for each element and then add MenuItem objects in their appropriate hierarchy.

Create an empty MainMenu, then Create MenuItem objects for each element, and then add MenuItem objects in their appropriate hierarchy. To create a menu completely at run time you will need to first create a MainMenu object. The MainMenu object will subsequently contain MenuItem objects that represent the first menu level. Each MenuItem object can in turn be a container for other MenuItem objects creating submenus.

After the creation of an empty MainMenu and after the MenuItem objects have been created for each element then add MenuItem objects in their appropriate hierarchy.

Create an empty MainMenu then Create MenuItem objects for each element and then add MenuItem objects in their appropriate hierarchy. To create a menu completely at run time you will need to first create a MainMenu object. The MainMenu object will subsequently contain MenuItem objects which represent the first menu level. Each MenuItem object can in turn be a container for other MenuItem objects creating submenus.


8. You are developing a process for a manufacturing application to be used on the company intranet. You want to return a string, "Pass" or "Fail" based on a decision made. You need to evaluate the TestMe parameter of the CheckIt procedure and return the word "Large" if the amount is greater than 1000; otherwise, it returns the word "Small". Which of the following represents the fewest number of commands in which this operation can be performed?

A.
Function CheckIt (ByVal TestMe As Integer) As String
CheckIt = IIf(TestMe > currAcc, "Pass", "Fail")
End Function
B.
Function CheckIt (ByVal TestMe As Integer) As String
If TestMe > currAcc then
CheckIt = "Pass"
Else
CheckIt = "Fail"
EndIf
End Function
C.
Function CheckIt (ByVal TestMe As Integer) As String
If TestMe > currAcc then
Return "Pass"
Else
Return "Fail"
EndIf
End Function
D.
Function CheckIt (ByVal TestMe As Integer) As String
CheckIt = "Fail"
If TestMe > currAcc then CheckIt = "Pass"
End Function

>> !
Answer: A

The IIf function returns one of two objects, depending on the evaluation of an expression, allowing the process to be performed in a single statement.

"Function CheckIt (ByVal TestMe As Integer) As String
If TestMe > currAcc then
CheckIt = "Pass"
Else
CheckIt = "Fail"
EndIf
End Function" works but is a lot more wordy than necessary

Function CheckIt (ByVal TestMe As Integer) As String
If TestMe > currAcc then
Return "Pass"
Else
Return "Fail"
EndIf
End Function works but is a lot more wordy than necessary

Function CheckIt (ByVal TestMe As Integer) As String
CheckIt = "Fail"
If TestMe > currAcc then CheckIt = "Pass"
End Function is a very good solution, but it could still be simplified


9. You are the primary developer on a large project that will be released as a series of Windows-based applications. One of the forms in the application contains a collection of text objects. You need to write code that will apply a business rule against every object in the collection. You need to scan each element for the existence of the string "Fail". MyObject is a text-related object and is an element of the collection MyCollection. If any element fails all elements will be rejected.

A.
Dim Found As Boolean = False
Dim MyObject, MyCollection As Object
For Each MyObject In MyCollection
If CStr(MyObject.Text) = "Fail" Then
Found = True
Exit For
End If
Next
B.
Dim Found As Boolean = False
Dim MyObject, MyCollection As Object
For Each MyObject In MyCollection
If CStr(MyObject.Text) = "Fail" Then
Found = True ' Set Found to True.
End If
Next
C.
Dim Found As Boolean = False
Dim MyObject, MyCollection As Object
For a = 1 to MyCollection.count - 1
If CStr(MyObject(a).Text) = "Fail" Then
Found = True
End If
Next
D.
Dim Found As Boolean = False
Dim MyObject, MyCollection As Object
If CStr(MyCollection.MyObject.Text) = "Fail" Then Found = True

>> !
Answer: A

"Dim Found As Boolean = False
Dim MyObject, MyCollection As Object
For Each MyObject In MyCollection
If CStr(MyObject.Text) = "Fail" Then
Found = True
Exit For
End If
Next" will cycle through each element exiting at the earliest point in which the collection has been deemed to fail.

"Dim Found As Boolean = False
Dim MyObject, MyCollection As Object
For Each MyObject In MyCollection
If CStr(MyObject.Text) = "Fail" Then
Found = True ' Set Found to True.
End If
Next" is a good solution but even after a failure has been found the code will still cycle through the remainder of the collection.

"Dim Found As Boolean = False
Dim MyObject, MyCollection As Object
For a = 1 to MyCollection.count - 1
If CStr(MyObject(a).Text) = "Fail" Then
Found = True
End If
Next" is a workable solution but the For is very inefficient in contrast to For Each.

"Dim Found As Boolean = False
Dim MyObject, MyCollection As Object
If CStr(MyCollection.MyObject.Text) = "Fail" Then Found = True" does not solve the problem as it does not cycle through every element of the collection.


10. You are preparing an application that is to be used by a number of government agencies at the municipal level to provide services to handicapped individuals in the community. In the application you want to code a name for each control that will identify the control such as a RedButton or ItalicTextBox. What property of the control would you set?

A. Name
B. AccessibleName
C. ShowFocusCues
D. IMEMode

>> !
Answer: B

The AccessibleName property allows the developer to get or set the name of a control used by accessibility client applications.

The Name property is usually used in a more generic manner to provide a name for a control so that it can be interacted with programmatically.

ShowFocusCues is a property that determines whether a control should display focus rectangles.

The IMEMode property is used to get or set the Input Method Editor (IME) mode of the control.


11. The retail company, that develop for has been using a Visual Studio project for some time. You use Visual Studio. NET to develop a Windows-based application. You plan to reuse a procedure written in Visual Basic 6.0. The procedure includes the following array declaration:

Dim Occupant (1 to 5) As String

You copy and paste the array declaration from the Visual Basic 6.0 project into the new VB .NET project. Now you must ensure that the Employees array will compile in the VB .NET application. What alterations must be made to support the code?

A. Dim Occupant(0 to 4) As String
B. Include Option Base 1 in the module Declaration
C. Include Option Base 0 in the module Declaration
D. Dim Occupant(4) As String

>> !
Answer: D

All arrays in Visual Studio.NET are zero based arrays. Optional bases are not supported.


12. The manufacturing company where you work as a developer is upgrading from Visual Basic 6 to Visual Basic .NET. Over the next several months you will be upgrading applications to the .NET framework. A routine that your company has been using stores date information into variables for numeric processing. The Visual Basic 6.0 program has been working flawlessly for some time. The code is as follows:

Dim dblDate As Double
Dim dat As Date
dat = Now
dblDate = dat
ProcessDate(dblDate)

What aspect of Visual Studio.NET will indicate a need to rewrite the code?

A. Visual Basic.NET does not support the storing of dates in double variables
B. The Now function does not returns date type
C. The Double data type has changed
D. You must use a CDate function to store a double back into the date

>> !
Answer: A

Earlier versions of Visual Basic supported using the Double data type to store and manipulate dates. You should not do this in Visual Basic .NET, because dates are not internally stored as doubles.

The return type of the Now function is a date. Earlier versions of Visual Basic supported using the Double data type to store and manipulate dates. You should not do this in Visual Basic .NET, because dates are not internally stored as doubles.
The double data type remains unchanged from previous versions. Earlier versions of Visual Basic supported using the Double data type to store and manipulate dates. You should not do this in Visual Basic .NET, because dates are not internally stored as doubles.


13. You are developing a Windows-based application for a large law office, Brindle, Brandle and Jones. The client side of an application you are developing will notify a process when an incoming file has arrived at a file server located on the network. A portion of the code is as follows:

Public Class Class1
Public Event FilePreserve_Event()
Sub FileArrived()
RaiseEvent FilePreserve_Event()
End Sub
End Class


Which of the following code will be required in the to handle the event?

A.
Sub Filed()
Dim Obj As New Class1()
AddHandler Obj.FilePreserve_Event, AddressOf EventHandler
Obj.FileArrived()
End Sub
Sub EventHandler()
' Handle the event.
End Sub
B.
Sub Filed()
Dim Obj As New Class1()
Call Obj.FilePreserve_Event, AddressOf EventHandler
Obj.FileArrived()
End Sub
Sub EventHandler()
' Handle the event.
End Sub
C.
Sub Filed()
Dim Obj As New Class1()
Call Obj.FilePreserve_Event, EventHandler
Obj.FileArrived()
End Sub
Sub EventHandler()
' Handle the event.
End Sub
D.
Sub Filed()
Dim Obj As New Class1()
AddHandler Obj.FilePreserve_Event, EventHandler
Obj.FileArrived()
End Sub
Sub EventHandler()
' Handle the event.
End Sub

>> !
Answer: A

The AddHandler statement allows you to start event handling at any time and provide the procedure address that will handle the event.

The AddHandler statement, not the Call operation, allows you to start event handling at any time and provide the procedure address that will handle the event.'

The AddHandler statement, not the Call operation, allows you to start event handling at any time and provide the procedure address using the AddressOf function.


14. You are working as a developer for a hobby machinery manufacturer. Shizoo Manufacturing Inc. The company manufactures and sells a variety of snowmobiles and equipment as well in the future it plans on releasing the new Jezoo Sea Ski. The model will be available in standard colors. The application you are developing must present these colors on the interface upon selection from a dropdown list box. Which of the following would be used define a set of named constants for the color schemes?

A.
Public Const InterfaceColors
MistyRose = &HE1E4FF&
SlateGray = &H908070&
DeepSkyBlue = &HFFBF00&
ForestGreen = &H228B22&
End Const
B.
Public Sub InterfaceColors
Const MistyRose = &HE1E4FF&
Const SlateGray = &H908070&
Const DeepSkyBlue = &HFFBF00&
Const ForestGreen = &H228B22&
End Sub
C.
Public Enum InterfaceColors
MistyRose = &HE1E4FF&
SlateGray = &H908070&
DeepSkyBlue = &HFFBF00&
ForestGreen = &H228B22&
End Enum
D.
Public Function InterfaceColors(Choice as string) As Color
Select Case Chocie
Case "MistyRose"
InterfaceColors = &HE1E4FF&
Case "SlateGray"
InterfaceColors = &H908070&
Case "DeepSkyBlue"
InterfaceColors = & HFFBF00&
Case Else
InterfaceColors = &H228B22& amp;
End Select
End Function

>> !
Answer: C

Enum is used at a module, class, or structure level to declare an enumeration of constants and define the values of its members.
Const is used for declaring singular constants, an enumeration must be used for multiple values. "Public Sub InterfaceColors Const MistyRose = &HE1E4FF& Const SlateGray = &H908070& Const DeepSkyBlue = &HFFBF00& Const ForestGreen = &H228B22&End Sub"in theory would work. You would have to declare a separate constant for each color that was created in the future. However, this could be an arduous update task if the colors ever change.
"Public Function InterfaceColors( Choice as string) As ColorSelect Case Chocie Case "MistyRose" InterfaceColors = &HE1E4FF& Case "SlateGray" InterfaceColors = &H908070& Case "DeepSkyBlue" InterfaceColors = & HFFBF00& Case Else InterfaceColors = &H228B22&End SelectEnd Function"A rather lucrative approach that may work but would require a lot of supporting code.


15. As a Visual Basic.NET developer you are designing a Windows-based application for a small retail store. You are using a multi-dimensional array to hold a series of integer values. At one stage during the processing you need to enlarge the array. You want to increase the size of the last dimension of an array without losing any existing data in the array. The original array is defined as follows:A = 10Dim IntArray(10, 10, A) As Integer How would you increase the size of the dynamic array?

A. A += 10
ReDim Preserve IntArray(10, 10, A)
B. A += 10
C. You cannot perform this operation without using a collection
D. A += 10
ReDim IntArray(10, 10, A)

>> !
Answer: A

Use the ReDim statement with the Preserve option to increase the size of an array while maintaining any current values.

The A variable does not affect the array unless reassigned using a ReDim statement.

Sure, you can perform this operation without using a collection. Although in many instances a collection is preferred over an array in this example a ReDim Preserve operation is really all that is required.

"A += 10
ReDim IntArray(10, 10, A)" would resize the array with a loss of data as without the Preserve operation the ReDim statement will empty the array.


16. You are creating a sales application using Visual Basic .NET for a small retail company. You have create the ICustomerInfo interface which is defined as follows:

Interface IcustomerInfo
Property CustomerName() As String
Sub UpdateCustomerStatus()
Event UpdateComplete()
End Interface

You now need to code the CustomerInfo class so that it can Use this inferface. Which of the following is correct for interface inheritance?

A. Public Class ICustomerInfo Implements CustomerInfo
B. Public Class CustomerInfo Inherits ICustomerInfo
C. Public Class CustomerInfo Inherits Interfaces ICustomerInfo
D. Public Class CustomerInfo Implements ICustomerInfo
E. Public Class ICustomerInfo Inherits CustomerInfo

>> !
Answer: D

The Implements statement specifies one or more interfaces, or interface members, that will be implemented in the class or structure definition in which it appears.

Inherits is full code inheritance which is not desired in this case.

You use the Implements keyword to provide interface inheritance is Visual Basic .NET.

Ensure that the new class inherits from the interface. Use the Implements keyword to inherit interfaces in a new class from an existing interface design


17. You are consulting for a large manufacturing organization that has a completely object oriented approach to development. Recently the have begun using Visual Basic .NET to implement the .NET framework in the organization's automated processes. An application that you are using needs to access the Microsoft.VisualBasic.Strings namespace and shortcut the namespace to a variable. Which of the following provides the requested functionality?

A.
Imports Str = Microsoft.VisualBasic.Strings
Class MyClass1
Function Sub ShowIt(Inne as String)
MsgBox(Str.Left(Inne, 5))
End Function
End Class
B.
Class MyClass1
Function Sub ShowIt(Inne as String)
Imports Str = Microsoft.VisualBasic.Strings
MsgBox(Str.Left(Inne, 5))
End Function
C.
Imports Microsoft.VisualBasic.Strings
Class MyClass1
Function Sub ShowIt(Inne as String)
Str = "Microsoft.VisualBasic.Strings"
MsgBox(Str.Left(Inne, 5))
End Function
D.
Imports Microsoft.VisualBasic.Strings
Class MyClass1
Function Sub ShowIt(Inne as String)
MsgBox(Microsoft.VisualBasic.Strings.Str.Left(Inne, 5))
End Function

>> !
Answer: A

The Imports statement allows access to namespace names from referenced projects and assemblies. Also imports namespace names defined within the same project as the file in which the statement appears. It can optionally be assigned to a variable to shorten coding of the namespace elements.

The Imports statement must always be the first code in a module.

"Class MyClass1 Function Sub ShowIt(Inne as String) Str = "Microsoft.VisualBasic.Strings" MsgBox(Str.Left(Inne, 5)) End Function" will not function as requested. The Str assignment should be made as part of the Imports statement.

"Imports Microsoft.VisualBasic.StringsClass MyClass1 Function Sub ShowIt(Inne as String) MsgBox(Microsoft.VisualBasic.Strings.Str.Left(Inne, 5)) End Function" will work but there has been no shortening of code per the original question.


18. You work for a small retail company that uses Visual Studio .NET products for the development of Windows-based applications. As one of several Visual Basic .NET developers you are designing an application that can optionally print the contents of client information from a Windows form. You implement standard .NET printing functionality and find that often only a portion of the information for a client is printed. Which of the following circumstances could be causing the problem?

A. QueryPageSettings did not set information for the current page
B. The user has no printers installed
C. The HasMorePages property of the PrintPageEventsArgs object is set to false
D. The default printer on the user's computer has been paused
E. The PrintPageEventArgs.Cancel property is set to true while the data is printing

>> !
Answer: C & E

The HasMorePages property of the PrintPageEventsArgs object is set to false. The PrintDocument.PrintPage Event has the HasMorePages property which gets or sets a value indicating whether an additional page should be printed.

The print job can be canceled partially through by if the PrintPageEventArgs. Cancel property gets set to true.

The QueryPageSettings method is optional and allows different settings to be used for each printed page.

The printed information should still be able to get to the queue. If the user's machine had no printer at all then as error could occur, but partial data would not even be printed.

If the user's machine had no printer at all then an error could occur, but partial data would not even be printed.


19. You work as a developer for a consulting firm that used Visual Studio .NET to deploy an application based on the .NET framework. You create a Windows-based application using Visual Basic .NET. The application will allow clients to prepare application outlines and then email the outline to a service account. You will need to distribute the application to your customers via an Internet download. You need to create a shortcut to your application on the User's desktop of the client's computer. What do you do in your setup project to accommodate the shortcut?

A. Provide an Icon for the main form and Visual Basic .NET will use this as the shortcut for the desktop
B. On the project properties of the application, indicate the location for the shortcut to be the User's desktop
C. On the setup program's properties of the application indicate the location for the shortcut to be the User's desktop
D. Select "Primary output" from the application. Create a Shortcut to the User's Desktop folder

>> !
Answer: D

To add a program shortcut, select the Installer project in Solution Explorer. In the File System Editor, select the Primary output from the application node. On the Action menu, choose Create Shortcut to. This will add a Shortcut to Primary output from My Notepad node. Rename the shortcut if desired. Select Shortcut to My NOTEPAD and drag it to the User's Desktop folder in the left pane.


20. You use Visual Studio .NET to create a Windows-based application. The application is used to accentuate presentations to management. You will use a form that appears transparent over the area it is covering. How do you accomplish this?

A. Set the foreground and background colors to white
B. Set the form's TransparencyKey to white
C. Set the foreground color to white
D. Set the form's opacity to zero percent
E. Display the form as a modal form
F. Set the forms background color to white

>> !
Answer: D

Setting the form's opacity to zero percent makes the form appear transparent over the area it is covering.

The TransparencyKey property will get or set the color that will represent transparent areas of the form.

Altering the forms foreground color does not implement transparency.

Altering the forms colors does not provide transparency.

Making a modal form does not make it a transparent form. It provides a form that must be interacted with the first of the forms visible.

White is not transparent.


21. You are the primary developer for a small retail store. You are working on an application that will handle credit card purchases from the store's data terminals. You use Visual Studio .NET to create a component named AuthorizeCredit. This component includes a method named Accept, which tries to process new purchases. Accept calls a private function named Validate. You must ensure that any problems encountered by the Validate function are returned to the form that contains the AuthorizeCredit component. What is the best solution?

A.
Try
Me.Validate()
Catch Exc As Exception
Throw Exc
End Try
B.
Me.Validate()
C.
Try
Me.Validate()
Catch Exc As Exception
Throw new Exception ("Exception in AcceptRequest", Exc)
End Try
D.
Catch e as OverflowException Throw New OverflowException( "An overflow occurred in the Widget component")

>> !
Answer: A

An exception can be "thrown" up to any parent component or class including the form class.

Me.Validate() would assume that the default behavior is to pass errors up to the parent, which is not the case.

It is not necessary to generate a new error, the existing error can be "thrown."

You would use the OverflowException option to generate an application specific error thrown back to the calling procedure.


22. You are a developer for a large consulting firm. The company has used Visual Studio .NET to create an accounting application. The application has a variety of classes for each significant interaction. One of the classes supported is the VendorAccountClass. This class instantiates several classes from a COM component that was created previously using Visual Basic 6.0. Each COM component class includes a custom method named CloseObject that must be called before terminating references to the class. When you run the application the COM component appears to remain in memory even after the application terminates. You must ensure that the CloseObject method of each COM component class is called before VendorAccountsClass is terminated. How do you fix the problem?

A. Add code to the Terminate event of VendorAccountsClass to call the CloseObject method of each COM component class.
B. Add the procedure Protected Overrides Finalize() to VendorAccountsClass. Add code to the procedure to call the CloseObject method of each COM component class.
C. Execute a DoEvents command in the Finalize routine for the component.
D. Execute a directory entry remove command from the finalize routine of the component.

>> !
Answer: B

The Sub Finalize procedure in Visual Basic .NET destroys objects.The terminate event had been used in previous releases of Visual Basic. Initialize and terminate have now been replaced with Sub New and Sub Finalize.

DoEvents will execute all pending Windows events but won't help free resources if garbage collection is not pending.

Directory entry remove is used to remove objects from Active Directory.


23. As a Visual Basic.NET developer you are creating a Windows-based application for a small retail company. During the finalization of processes the application will need to record entries into the registry on the client's computer. You need to create a registry key that has two subordinate keys. What code is required?

A.
SaveSetting("RetailApp","Startup","NumberOne","Entry1")
SaveSetting("RetailApp","NumberOne","NumberOneAy","Entry1A")
SaveSetting("RetailApp","NumberOne","NumberOneBee","Entry1B")
B.
SaveSetting("RetailApp","Startup","NumberOne","Entry1")
SetAttr("RetailApp NumberOne NumberOneAy Entry1A", vbReadOnly)
SetAttr("RetailApp NumberOne NumberOneBee Entry1B", vbReadOnly)
C.
SaveSetting("RetailApp","Startup","NumberOne","Entry1")
SSett = RSet("RetailApp, NumberOne, NumberOneAy, Entry1A", 10)
SSett = RSet("RetailApp, NumberOne, NumberOneBee, Entry1B", 10)
D.
SaveSetting("RetailApp","Startup","NumberOne","Entry1")
SSett.Add("RetailApp NumberOne NumberOneAy Entry1A", vbReadOnly)
SSett.Add("RetailApp NumberOne NumberOneBee Entry1B", vbReadOnly)

>> !
Answer: A

The SaveSetting operation is used to create any registry key off of the application "RetailApp" regardless of depth.

A DataMember first requires a DataSource. The BoundColumn represents a column bound to a field in a data source. It displays each item in the field as text, potentially used later in the application..

A BoundColumn first requires a DataMember. The SetAttr command is used to set attribute information for a file.

RSet will returns a right-aligned string containing the specified string adjusted to the specified length. The Add method adds an element to a collection.


24. You are a developer for the small accounting firm, Book 'Em. You use Visual Studio .NET as your primary tool to create a Windows-based application. You are working with an application that will display profit and loss figures for the past ten years. The application uses line graphs plotted to specific pixel locations on the display form ShowsItForm. Because of the nature of the display you would like the form to always be a static size. To ensure that a user cannot resize, minimize, or maximize the form you will have to alter a number of properties. Which three settings would you ensure are present? Each answer will represent a portion of the solution. . . (Choose all that apply)

A. Set ShowsItForm.MaximizeBox to False
B. Set ShowsItForm.MinimizeBox to False
C. Set ShowsItForm.Size and Location properties to specific Width and Height
D. Set ShowsItForm to be displayed as a modal dialogue
E. Set ShowsItForm.FormBorderStyle to one of the Fixed styles
F. Set ShowsItForm.WindowState to Maximized

>> !
Answer: A, B & E

You want to ensure that the user cannot alter the size of the form while preventing it from being maximized or minimized which would also cause a similar problem when the form is redrawn. You will have to disable the maximize and minimize buttons and provide a fixed, unchangeable border.

Setting the size and location will not prevent the form from being altered. When the application is executing you will be able to change from the size or location originally defined. A modal dialogue will only serve to prevent the user from accessing other parts of the application; it does not prevent resizing.

A Maximized form will only start out covering the screen. It does not prevent the user from resizing the form.


25. You are the developer for a construction company that develops large parcels of land in very remote areas. Most of these parcels will be purchased by corporate executives from large companies as retreats. Each of the parcels of land has essentially the same base information but also each will have special considerations. You create the basic form with the common elements. You want this form to be inherited and then added to at run time. The newly combined form will have both the base elements and the elements specific to the current parcel. The namespace of the current project is ParcelPro while the namespace that the original form resides in is called GenericParcels. You have made a reference to the GenericParcels namespace. What code is needed to use the BaseForm created?

A. Dim Form2 as New GenericParcels.BaseForm
B. Dim Form2 as New ParcelPro.BaseForm
C. Public Class Form2 Inherits ParcelPro.BaseForm
D. Public Class Form2 Inherits GenericParcels.BaseForm

>> !
Answer: D

You create a new class that inherits from the BaseForm and within the sub-class you can then provide additional features specific to the parcel.

Dim Form2 as New GenericParcels.BaseForm is not a good solution. You are using a class all techniques used in inheriting and sub-classing are available.

In using Windows forms, each form is represented by a class. Since you are using a class, all techniques used in inheriting and sub-classing are available. You therefore create a new class that inherits from the BaseForm and within the sub-class you can then provide additional features specific to the parcel.


26. As a Visual Basic.NET developer for a small retail franchise, you are creating an application that will act as a server component for a variety of clients. Your component will be used by other Visual Studio .NET language applications and legacy environments as well. You want to create a single assembly and use that assembly to install and register the component on all clients. What should you do?

A. Use Assembly Registration tool (Regasm) to generate a type library file.
B. Use Assembly Registration tool (Regasm) to generate a registry file.
C. Use the Type Library Exporter tool (Tlbexp) to generate a registry file.
D. Use the Type Library Exporter tool (Tlbexp) to generate a type library file.

>> !
Answer: B

A registry file is needed so that the application can be both installed and registered. The appropriate tool is therefore the Assembly Registration tool.

If you desire a type library file the appropriate tool would be the Type Library Exporter tool. If you desire a component both installed and registered you should have the Assembly Registration tool generate a registry file.

Use the Type Library Exporter tool (Tlbexp) to generate a type library file.

If you desire a component both installed and registered you should have the Assembly Registration tool generate a registry file. The Type Library Exporter tool is used to create type library files.


27. You are developing a set of Windows-based applications. The applications that you are building can each run as a stand alone application or contribute information to each other in alternate instances. You must ensure that when running on the same machine the two applications can share information while at the same time run independently when needed. How would you deploy the assemblies?

A. Use the Global Assembly cache tool to ensure that the applications communicate through the common runtime environment.
B. Use the Assembly linker to unite the resources used by each application.
C. Use the Certificate Management tool and apply the same certificate to all applications.
D. Ensure that calls to other applications are passed through the Web Services Discovery tool.

>> !
Answer: A

The common language runtime has a machine-wide code cache called the global assembly cache. The global assembly cache stores assemblies specifically designated to be shared by several applications on the computer.

Certificates are a security implementation and have nothing to do with shared resources.

The Assembly Linker generates a file from one or more files that are either modules or resource files.

The Web Services Discovery tool discovers the URLs of XML Web services located on a Web server and saves documents related to each XML Web service on a local disk.


28. You are working as a Visual Studio.NET developer for a small retail company. You are about to deploy an application to the computers in the administrative office. You create an application configuration file that will be installed on the client computer along with the application. You must ensure that the settings in the application configuration file are applied to the application it is executed. How do you deploy the configuration?

A. Give the configuration the same name as the application with a ".exe" extension and then copy it to the Windows\System32 folder.
B. Give the configuration the same name as the application with a ".exe" extension and then copy it to the global assembly cache.
C. Give the configuration the same name as the application with a "cfg" extension and then copy it to the Windows\Sytem32 folder.
D. Give the configuration the same name as the application with an ".exe" extension and then copy it to the application folder.
E. Give the configuration the same name as the application with a ".cfg" extension and then copy it to the global assembly cache.
F. Give the configuration the same name as the application with a ".cfg" extension and then copy it to the application folder.

>> !
Answer: D

The configuration file needs to be installed to the application folder with an ".exe" extension.

Giving the configuration the same name as the application with a ".exe" extension and then copying it to the Windows\System32 folder is not a good solution. The configuration file needs to be installed to the application folder not the operating system folder.

Giving the configuration the same name as the application with a ".cfg" extension and then copying it to the application folder is not a good solution. The configuration file has to have an ".exe" extension.

The configuration file needs to be installed to the application folder not the global assembly cache.

Giving the configuration the same name as the application with a "cfg" extension and then copying it to the Windows\Sytem32 folder is not a good solution. The configuration file needs to be installed to the application folder with an ".exe" extension. The configuration file needs to be installed to the application folder with an ".exe" extension.

Giving the configuration the same name as the application with a ".cfg" extension and then copying it to the global assembly cache is not a good solution. The configuration file needs to be installed to the application folder, not the global assembly cache, with a ".exe" extension, not ".cfg".


29. You are working for a large manufacturing firm that has standardized development on the .NET Framework as its software development platform, Visual Studio.NET. The company has a policy of not allowing execution of any applications downloaded from the Internet because of virus problems and other security concerns. You must ensure that all client computers on your intranet can execute all .NET applications originating from your company but not allow any from the Internet. Which type of policy should you implement?

A. Machine
B. Application Domain
C. Enterprise
D. User

>> !
Answer: C

An Enterprise policy applies to the whole domain and would require minimal administration.

An Application Domain policy is defined by the runtime host. This policy level cannot be administered. A machine policy applies only to the machine it is configured for.

A user policy applies only to the user it is configured for.


30. You are working as one of the primary developers for a large construction company that has a variety of properties in the area. The development team is currently working on a number of applications that communicate using a Windows-based application and XML Web services. A WAN outage has caused a disconnected state between the server containing the Web Services and your development environment. You need to develop the client solely based on the content of the Web Services description file. its description file. How can you begin the coding of the client interface?

A. Use the Soapsuds tool to compile the application.
B. Use the Discovery tool to gain access to the Web Services.
C. Use Web Services Description Language tool to generate a proxy class for each service.
D. Use the Isolated Storage tool to access the Web Services description.

>> !
Answer: C

You will first need to reference the Web Services. When you create a reference the development environment creates a proxy on your behalf. You can manually generate a proxy using the XML Web Services Description Language tool, Wsdl.exe.

The Web Services discovery tool is used to help discover the location of web services.

The Soapsuds tool uses remoting to compile client applications that communicate with XML Web services.

The Isolated Storage tool lists or removes all existing stores for the current user.


31. You are preparing a task management application that uses the TaskMgmtWS Web service to update a DataGrid control. The application starts by instantiating an XML Web service object named ws. Then, a call is made to the web method GetTasks() to get an ADO.NET DataSet of tasks. You now need to set up the tasks DataSet. You have the following code: (Numbers are added for reference only)
  1. ' Call the Web service.
  2. Dim ws As localhost.Service1 = New localhost.Service1()
  3. Dim ds As DataSet = ws.GetTasks()
  4. Connect the data DataGrid control.
What commands would you place at lines 5 and 6?

A. DataGrid1.DataSource = dsDataGrid1.BoundColumn = "Tasks"
B. DataGrid1.DataSource = "Tasks"DataGrid1.DataMember = ds
C. DataGrid1.DataMember = dsDataGrid1.BoundColumn = "Tasks"
D. DataGrid1.DataSource = dsDataGrid1.DataMember = "Tasks"

>> !
Answer: D

A DataMember first requires a DataSource. The BoundColumn represents a column bound to a field in a data source. It displays each item in the field as text, potentially used later in the application.


32. You are the primary developer working as a consultant for a large manufacturing company, ACME Widgets. You develop a Windows-Based application that accesses a SQL Server. Users supply a user name and password when they start the application. This user id and password supplied is then used to dynamically build a connection string and log the user in as a standard SQL user across non-trusted connections. When you test the application, you discover that it is not using the SqlClient connection pooling feature. How should you modify the connection string?

A. Use the SQL Server used login when connecting to the database.
B. Use the same logon ID and password for every connection.
C. Use the guest login ID and password for every connection.
D. Use the Windows user logon when connection to the database.

>> !
Answer: B

To use a connection pool you must use the same connection string.

Using the SQL Server used login when connecting to the database is what is currently being performed and it's causing problems because each connection uses a different id and password.

The guest account may be disabled and is otherwise a poor choice for most applications.

A windows login would not provide connection capabilities for non-trusted connections though you could unify the connections string.


33. You are one of many developers that work as a team in a large manufacturing company, ACME Widgets. Your team is developing a 3-tier application that includes a Windows-based user interface, business logic supplied by middle-tier components, and a large data warehouse operating on Microsoft SQL Server. You are in the process of creating one of the middle-tier components. The component will be accessing data on behalf of the user. The process involves calling several SQL Server stored procedures. These procedures must run under the umbrella of a single transaction. You must prevent two users from being able to update the same data concurrently. Select One

A.
Dim conn As New SqlConnection()
Dim tran As SqlTransaction
tran = cn.BeginTransaction(IsolationLevel.Serializable)
B.
Dim conn As New SqlConnection()
Dim tran As SqlTransaction
tran = conn.BeginTransaction("ReadCommitted")
C.
Dim conn As New SqlConnection()
Dim tran As SqlTransaction
tran = conn.BeginTransaction(IsolationLevel.ReadCommitted)
D.
Dim conn As New SqlConnection()
Dim tran As SqlTransaction
tran = conn.BeginTransaction("Serializable")

>> !
Answer: D

Serializable provides for the highest transaction isolation level providing protection against concurrent data access errors. This is always set as an option to a transaction as a setting of the isolation level object.

Serializable provides for the highest transaction isolation level, providing protection against concurrent data access errors. This is always set as an option to a transaction.

Serializable provides for the highest transaction isolation level, providing protection against concurrent data access errors. With ReadCommitted, shared locks are held while the data is being read to avoid dirty reads, but the data can be changed before the end of the transaction, resulting in non-repeatable reads or phantom data. This is always set as an option to a transaction as a setting of the isolation level object.

With ReadCommitted, shared locks are held while the data is being read to avoid dirty reads, but the data can be changed before the end of the transaction, resulting in non-repeatable reads or phantom data.


34. You are working as a developer for a small retail operation that deals with many different wholesalers form around the world. You are developing a Windows-based application using Visual Basic .NET. Your application will receive XML data from the separate vendors and associate the supplied XML Schema so that the format and the data types for the XML data can be applied against the same database. The process in your application must take the XML data and make sure that it is valid by using the schema supplied. How do you ensure the data is valid?

A. Implement an XmlValidatingReader object and code an event handler.
B. Implement an XmlValidatingReader object and examine the errors collection.
C. Implement the XMLValidatingReader and examine the CanResolveEntity property.
D. Implement the XMLValidatingReader and cycle through the data testing the data against middle tier business rules.

>> !
Answer: A

Implementing an XmlValidatingReader object and coding an event handler will ensure the data is valid.

The errors collection will only show errors is the Visual Basic processing cycle not data errors presented by the XMLValidatingReader object.

The CanResolveEntity property is used to solely indicate whether the application can parse the XML.

Although possible, implementing the XMLValidatingReader and cycling through the data testing the data against middle tier business rules would be a grueling exercise. The validation of XML is best performed using the Schema as no programmed logic is required.


35. You are one of the primary developers for a large manufacturing organization ACME Widgets. You are working with a team of developers to create an inventory management application. The application will interact with a database on a SQL Server that is located on the company intranet. You need to display information in a text property of the PurchaseOrder object. You need to access a stored procedure on the server to perform some of the functionality in your application. The stored procedure will provide calculated information and return the result from the call as an output parameter. Thus far the code for the routine is as follows:Dim cnn As SqlConnection = New SqlConnection(myCStr) Dim cmd As SqlCommand = New SqlCommand("sp_CalculatePurchaseLevel", cnn) cmd.CommandType = CommandType.StoredProcedure Dim parm As SqlParameter = cmd.Parameters.Add("@CRes", SqlDbType.Int) parm.Direction =ParameterDirection.Output cnn.Open() cmd.ExecuteNonQuery() Which code segment is now needed?

A. CalcResultString = cmd.Parameters("@CRes").Value.ToString())
B. CalcResultString = cmd.Parameters("@Output").Value.ToString())
C. CalcResultString = cmd.Parameters("@Output").ToString())
D. CalcResult = cmd.Parameters("@CRes").ToString())

>> !
Answer: A

The @CRes parameter is the integer output parameter. The Value property of the SQLParameter class is used to access the value of CRes. Convert the INT value to a string value using ToString. The name of the output parameter is required, not the type of parameter.

The name of the output parameter is required, not the type of parameter.

The value property must be explicitly declared.


36. You use Visual Basic .NET to develop a Windows-based application for a large manufacturing company ACME Widgets. Your application will display data retrieved from a Microsoft SQL Server database. The data is displayed on a Windows Form with invoice general information in text boxes and detail data in a grid control named InvoiceGrid. InvoiceGrid has been bound to a DataView object named InvDatVw. InvoiceGrid displays invoice information for the current order being processed and that information can be identified by the InvoiceNumberID. The InvoiceNumberID is held in a drop down list box called InvoiceIDList. How do you ensure that only the necessary data is stored in a local recordset?

A. Set the RowFilter property of the DataView object to "InvoiceNumberID = " & InvoiceIDList.Text"
B. Set the RowFilter property of the DataView object to "InvoiceNumberID = " & InvoiceIDList.SelectedText"
C. Set the RowFilter property of the DataView object to "InvoiceNumberID = " & InvoiceIDList.ItemData"
D. Set the RowStateFilter property of the DataView object to "InvoiceNumberID = " & InvoiceIDList.Text"
E. Use the FindRows method of the DataView object to filter based on the "InvoiceNumberID = " & InvoiceIDList.Text"

>> !
Answer: A

You would need to set the RowFilter to the value that is in the text box.

The SelectedText property refers only to highlighted text used with SelectionStart and SelectionLength.

ItemData was used in previous versions of Visual Basic but in not supported in Visual Basic .NET

The RowStateFilter is used to filter based on the state of the record not a test expression.

The FindRows method will return an array of DataRowView objects whose columns match the specified sort key value.


37. You are a Windows-based developer that uses Visual Basic .NET to create data aware applications that interact in two and three-tier environments. You want to create an application that will let sales clerks enter purchase orders. The application you are creating uses a DataSet and two DataTable objects. The purchase order will act as a primary key for the orders table while the order details table will use the purchase order and a sequential identity column set by SQL Server. There is a one-to-many relationship between orders and order items. How would your application define the primary keys?

A. On the PurchaseOrder DataTable set the PrimaryKey property to a single element array referencing the PurchaseOrderNumber field and set the PrimaryKey property of the PurchaseOrderDetails DataTable to an array of DataColumn objects that reference the two columns that make up the primary key.
B. On the PurchaseOrder DataTable set the PrimaryKey property to the PurchaseOrderNumber field and set the PrimaryKey property of the PurchaseOrderDetails DataTable to an array of DataColumn objects that reference the two columns that make up the primary key.
C. On the PurchaseOrder DataTable set the PrimaryKey property to the PurchaseOrderNumber field and set the PrimaryKey property of the PurchaseOrderDetails DataTable to a concatenation of the two columns that make up the primary key.
D. On the PurchaseOrder DataTable set the PrimaryKey property to the PurchaseOrderNumber field and set the PrimaryKey property of the PurchaseOrderDetails DataTable to the two columns that make up the primary key separated by a comma.

>> !
Answer: A

The PrimaryKey property gets or sets an array of columns that function as primary keys for the data table.

Both PrimaryKey properties must be set to an array of DataColumn objects.

The PrimaryKey property will only accept an array.


38. You are working on a new contract for a small consulting firm TOMORA Systems. You are in the process of developing a Windows-based application that generates output in the form of XML data. The XML output is generated by using the WriteXml method of the DataSet object. Once the data has been generated it is then sent to another application where the output is very specific in nature. You need to write the Visual Basic .NET code that will format the XML output for the second application. What code would you supply?

A. FirstDataSet.WriteXmlSchema(txtFilename)
B. FirstDataSet.WriteXmlSchema(txtFilename, XmlWriteMode.WriteSchema)
C. FirstDataSet.WriteXml(txtFilename, XmlWriteMode.WriteSchema)
D. FirstDataSet.WriteXmlSchema(txtFilename)

>> !
Answer: C

To have the data prepared to a specific structure you should supply the schema with the XML data output.

The WriteXMLSchema only writes the schema not the data and there is no WriteSchema option for this command as the schema is generated by default.

With the FirstDataSet.WriteXmlSchema(txtFilename) command you would only get the data not the supporting schema which is generally needed to work between two separate applications.

With the WriteXmlSchema method you only generate the schema with no data.


39. You are the primary Visual Basic developer on a team that uses Visual Studio .NET to develop Windows-based applications for a large manufacturing firm, ACME Widgets. The current application that you are debugging will connect to a Microsoft SQL Server database. When any error occurs as the user executes stored procedures from the database you would like to identify the situation. You are going to perform structured error handling in the application to capture the information about any of the errors. How would you identify errors in stored procedure calls?

A.
Try
dbConnection.Open()
Catch dbError as SQLException
' Error-handle.
End Try
B.
Try
dbConnection.Open()
Catch dbError as SQLCommand
' Error-handle.
End Try
C.
Try
dbConnection.Open()
Catch dbError as SQLConnection
' Error-handle.
End Try
D.
Try
dbConnection.Open()
Catch dbError as SQLDebugging
' Error-handle.
End Try
E.
Try
dbConnection.Open()
Catch dbError as SQLParameter
' Error-handle.
End Try
F.
Try
dbConnection.Open()
Catch dbError as SQLTransaction
' Error-handle.
End try

>> !
Answer: A

To identify errors in stored procedure calls, use the SQLException object.

"Try
dbConnection.Open()
Catch dbError as SQLCommand
' Error-handle.
End Try" represents a Transact-SQL statement or stored procedure to execute against a SQL Server database, not an exception.

"Try
dbConnection.Open()
Catch dbError as SQLConnection
' Error-handle.
End Try" represents an open connection to a SQL Server database. This class cannot be inherited not the error state.

The SQLDebugging type supports the .NET Framework infrastructure and is not intended to be used directly from your code.

"Try
dbConnection.Open()
Catch dbError as SQLParameter
' Error-handle.
End Try" represents a parameter to a SqlCommand, and optionally, its mapping to DataSet columns. It does not directly relate to error handling.

"Try
dbConnection.Open()
Catch dbError as SQLTransaction
' Error-handle.
End try" represents a Transact-SQL transaction to be made in a SQL Server database and does not directly relate to error handling.


40. You are working as one of a team of developers for a consulting firm that performs systems integrations for various municipal governments. You develop a Windows-based application that interacts with several data stores on a Microsoft SQL Server that is located on the corporate network. The network has no external access to or from the Internet. You would like to optimize query performance for repeated execution of the same stored procedure. It seems that the first daily execution of the application does not respond quickly enough though subsequent executions are reasonable. How can you improve the performance of the initial execution?

A. Call the SqlCommand.ResetCommandTimeout method on every call to a stored procedure.
B. Call the SqlCommand.Prepare method on every call to a stored procedure.
C. Call the SqlCommand.ExecuteReader method during the application's initialization phase.
D. Call the SqlCommand.ExecuteReader method on every call to a stored procedure.
E. Call the SqlCommand.Prepare method during the application's initialization phase.
F. Call the SqlCommand.ResetCommandTimeout method during the application's initialization phase.

>> !
Answer: E

SqlCommand.Prepare improves the efficiency of the first call to a stored procedure by performing all server side preparations and query optimizations.

A preparation is not normally needed for subsequent calls to the same stored procedure.

"Call the SqlCommand.ExecuteReader method during the application's initialization phase" sends the CommandText to the Connection and builds a SqlDataReader and will not usually affect performance.

"Call the SqlCommand.ExecuteReader method on every call to a stored procedure" sends the CommandText to the Connection and builds a SqlDataReader and will not usually effect performance.

All the "Call the SqlCommand.ResetCommandTimeout method during the application's initialization phase" function does is resets the timeout value to its default and will not affect performance.


41. You are working as a member of a team of consultants that use Visual Studio .NET as the primary development tool. The Windows-based application that you are currently designing uses a SqlConnection object for database access. You typically run this application on a computer that has limited resources and you need to minimize the use of the application's local resources when dealing with large amounts of data. How do you ensure the SQLConnection is closed after it has completed its processing?

A. Call the SQLConnection.GetDeleteCommand.
B. Set the SQLConnection.DataAdapter property to false.
C. Call SQLConnection.Dispose.
D. Call SQLConnection.RefreshSchema.

>> !
Answer: C

Dispose is used to release the resources used by an object.

The SqlDataAdapter is an object via which Transact-SQL statements are automatically generated.

Gets the SqlCommand object required to perform deletions on the database when an application calls Update on the SqlDataAdapter.

"Call SQLConnection.RefreshSchema" refreshes the database schema information used to generate INSERT, UPDATE, or DELETE statements.


42. You are working as a Visual Basic developer for a large construction company that specializes in purchasing and developing tracks of land that have been contaminated with environmental waste. You develop a Windows-based application that will track the cleaning of the soil from the sites. The soil must be totally removed and put through a sterilization process before it is safe for use. The database used to store the information is stored on a Microsoft SQL Server. Additions to the database will be made through a DataSet. You need to add tables to the existing DataSet. What is used to add the required tables?

A. Use the Component Designer in a form or component.
B. Use the XML Designer to modify the dataset schema.
C. Have an SQL stored procedure produce the desired table from the query builder.
D. Attach a file DSN to the project.
E. You cannot add more tables.

>> !
Answer: A & B

Use the Component Designer in a form or component. Using the Component Designer in a form or component is an easy solution that allows you to drag elements onto the form or component and then regenerate a modified dataset.

Using the XML Designer to modify the dataset schema is useful if you do not want or need to open a form or component. Adding a table using the XML Designer is similar to creating the schema manually.

Having an SQL stored procedure produce the desired table from the query builder is not what we are looking for in this case. A stored procedure will produce a record set object. A file DSN is used in development to access a data source.


43. You are developing a Windows-base application that will retrieve an XML file and schema. Once the information is retrieved, your application must obtain a copy of the structure of the DataSet including all components. The operation needs to be performed without copying the data. How do you obtain this functionality?

A. Use the Copy method of the DataSet object.
B. Use the Clone method of the DataSet object.
C. Use the GetSchemaSerializable method of the DataSet object.
D. Use the Merge method of the DataSet object.

>> !
Answer: B

The clone method will copy the structure of the DataSet, including all DataTable schemas, relations, and constraints. It does not copy any data.

Using the GetSchemaSerializable method of the DataSet object supports the .NET Framework infrastructure and is not intended to be used directly from your code.

Using the Merge method of the DataSet object would merge two DataSet objects.


44. You are developing a Windows-based application using Visual Basic .NET for a large manufacturing operation. The application will allow users to enter data in a series of text boxes. You must then have the application find the appropriate data from the database and allow standard add, change and delete operations to be performed. You want the users to have some flexibility on data entry searches so you would like to allow a search by entering only the first few characters of the last name being searched on. You would like to use a standard SQL query to accommodate this action. Which of the following is correct for the application?

A. SQL = "SELECT * FROM Addresses WHERE LastName LIKE ''" & txtLastNameSearch & "%' "
B. SQL = "SELECT * FROM Addresses WHERE LastName LIKE ''" & txtLastNameSearch & "*' ".
C. The query must end up looking like SELECT * FROM Addresses WHERE Lastname IN "Jon%"
D. The query must end up looking like SELECT * FROM Addresses WHERE Lastname = "Jon%"
E. The query must end up looking like SELECT * FROM Addresses WHERE Lastname = "Jon*"

>> !
Answer: A

The query must end up looking like SELECT * FROM Addresses WHERE Lastname Like "Jon%"

"SQL = "SELECT * FROM Addresses WHERE LastName LIKE ''" & txtLastNameSearch & "*' "The % sign needs to be where the second * is placed for the condition. The query must end up looking like SELECT * FROM Addresses WHERE Lastname Like "Jon%".

The IN operation is used to find a match within a list. The LIKE operation is used when a portion of the search text is provided.

The = will look for an exact character match for Jon% it would not return Jones etc.

The = will look for an exact character match for Jon*. It would not return Jones, etc.


45. You use Visual Studio .NET to develop applications for a large manufacturing firm, ACME Widgets. The majority of the applications run across the corporate intranet using IIS web servers. All client computers have been standardized with Internet Explorer version 6.0. You plan to distribute your current application to all users through a web page link on a portion of the intranet set aside for application maintenance. The company has set up a policy whereby all applications must be able to be uninstalled through the control panel. What type of project would you create for your application? Select the most appropriate answer:

A. CAB
B. Merge Module
C. Setup
D. Web Setup

>> !
Answer: D

Create a Web Setup project to deploy the application to an IIS server. To deploy a Web application, you need to create a Web Setup project. With this project you build the application and copy it to a virtual directory on an IIS or other Web server. You will then need to run the installer to have the application installed on the server.

Cab projects create a .cab file for ActiveX components that can be downloaded from a Web server to a compliant browser.

Merge Module projects are used to package files or components into a single module allowing the sharing of components across multiple applications.

Setup project creates a "standard" installation program for local installs.


46. You are working as one of a number of developers on a consulting team for TOMORA Systems. You want to configure Control Panel support for an application you are developing. Particularly you would like the company name supplied as the support contact by the Add/Remove Programs option. Which property should you change?

A. Manufacturer in the Application Project.
B. Author in the Application Project.
C. Manufacturer in the Setup Project.
D. Author in the Setup Project.

>> !
Answer: D

The Author property specifies the name of the author of an application or component being installed. The Setup project takes the necessary steps in communicating this information to the operating system.

Author in the Application Project is not a good solution. The Setup project takes the necessary steps in communicating this information to the operating system.

The Author property specifies the name of the author of an application or component being installed. The Manufacturer property specifies the name of the manufacturer of an application or component. The Manufacturer property is displayed as the application Publisher.

The Manufacturer property specifies the name of the manufacturer of an application or component. The Manufacturer property is displayed as the application Publisher.


47. You are working as a consultant on an extended contract for a large manufacturing company, ACME Widgets. You have created several useful ActiveX controls that you would like to protect against unauthorized use or alteration. You have to ensure that ACME can make full use of the control while protecting against the unlicensed use by other individuals or companies. You decide to use a license implemented by through the LicFileLicense Provider class. What must you do to protect the controls?

A. Make a call to LicenseManager.Validate in the control's load event.
B. Make a call to LicenseManager.CreateWithContext in the control's load event.
C. Apply a LicenseProviderAttribute to the class of each control.
D. Make a call to LicenseManager.LockContext in the control's load event.
E. Apply a LicenseException to the class of each control.

>> !
Answer: A & C

Make a call to LicenseManager.Validate in the constructor and apply a LicenseProviderAttribute to the class. To enable licensing of any control or component, apply a LicenseProviderAttribute to the class. To ensure the component or control is licensed call LicenseManager.Validate or LicenseManager.IsValid in the constructor.

To enable licensing of any control or component, apply a LicenseProviderAttribute to the class. To ensure the component or control is licensed call LicenseManager.Validate or LicenseManager.IsValid in the constructor.

CreateWithContext is used to create an instance of a licensed object.

LockContext prevents changes from being made to the current LicenseContext of a given object.

The LicenseException is an exception thrown if the component cannot be granted a license.


48. You are working as a maintenance developer for a Midwestern Farming Cooperative. You have been assigned to alter an existing application that was created by another developer who has since left. After making a few minor alterations you try to build the application. The results of the compilation indicate numerous syntactical errors. In order to correct the errors as quickly as possible you need to find each error. Where would a list of errors be found?

A. The Dynamic Help Window
B. The Command Window
C. The Object Browser
D. In the code editor
E. The Application event log
F. The Task List window

>> !
Answer: F

The Task List window helps to organize the tasks yet to be completed. Among other useful features, this window will include each syntax error found in the application.

Dynamic help is a new feature where you can view a list of samples, topics, and other information based on your current selection context.

The Command window is an amalgamation of a command line and Visual Basic's Immediate window. You can make use of this window in testing what/if scenarios and other conditional execution.

The Object Browser allows you to see any referenced object in the application namespace.

Although code editor is a sure way to eventually find all errors, it certainly isn't the quickest.

The Application event log is used to show runtime messages from the applications running on the computer.


49. You are working for an international company that has satellite offices around the globe. The company has standardized all operations around the .NET development platform and is in the process of upgrading all of its applications. The company needs an application that can operate within all cultural environments. How do you deploy the application?

A. As a separate application for each language.
B. Create a single application. Create a separate form for each language.
C. Create separate resource files for each culture using the Windows Forms Resource Editor.
D. Create a single application and provide a separate language file for each culture.

>> !
Answer: C

The Windows Forms Resource Editor is a visual layout tool that provides for localization of applications across cultures. The .resx or .resources files that are used as input to Winres.exe can be created using a visual design environment such as Microsoft Visual Studio .NET.

A separate application for each language would be far too inconvenient not to mention the additional man hours needed to create a separate application for each culture.

Creating a single application and then creating a separate form for each language would be far too inconvenient. That and the additional man hours needed to create a separate form for each culture would make this impractical. Imagine the difficulty if there were 10 different forms in the application. Very, very bulky.

Creating a single application and provide a separate language file for each culture is not a good solution. A resource file is required to localize an application.


50. You are working as one of the primary Visual Studio.NET developers for a small manufacturing company ACME Widgets. You are currently working on a project that will use a Windows-based application. The application will perform numerous Assert, Deny and PermitOnly security operations while it is executing. You must ensure that the application is optimized for fast run-time execution without interfering or compromising the security operations. How should you optimize the security?

A. Perform Imperative Security Checks.
B. Perform declarative security checks.
C. Use SQL Server Security options.
D. Use the Operating Security options.

>> !
Answer: B

Declarative security checks in an application of this type would generally be the most efficient fastest solution without compromising security.

Imperative security checks will not function in this instance as they allow you to protect specific blocks of code by requiring appropriate permissions but it cannot be used in applications that perform Assert, Deny, and/or PermitOnly operations.

SQL Server security would be more scalable allowing for easier deployment in enterprise operations, but this security mechanism is less optimized for the .NET framework security implementations.

The Operating Systems is best suited to file and network connection control. Although other object security is available through Active Directory installations it would only be used in this case as additional security measures.


51. You are one of many Visual Studio .NET developers that work for a large web integration company. You are performing the deployment of a series of your own applications. You are concerned that the application's functionality may be lost if other developers overwrite your installation with your own. How would you secure your assembly?

A. Ensure the assembly is not deployed to the Global Assembly Cache.
B. Create a strong name assembly using the strong Name tool (Sn.exe).
C. Create an Assembly manifest for the application.
D. Use the MarshalByRefObject Class.

>> !
Answer: B

A strong name consists of the assembly's identity - its simple text name, version number, and culture information. It is generated from an assembly file.

Assemblies with the same strong name are expected to be identical.

Ensuring the assembly is not deployed to the Global Assembly Cache will help protect the resources used by the application but does not supply the degree of uniqueness needed.

The assembly manifest only contains a collection of data that describes how the elements in the assembly relate to each other.

The MarshalByRefObject Class enables access to objects across application domain boundaries in applications that support remoting.


52. Which of the following are malicious threats to network security?

A. Viruses
B. Earthquakes
C. Hackers and crackers
D. Employees who don't know any better
E. Power failures
F. Disgruntled employees

>> !
Answer: A, C & F

By definition, malicious threats to a network are caused or produced by human beings who do it on purpose. DoS Attacks, Smurfing, Brute Force and other forms of attack also are considered malicious. However, outside forces of nature that damage the network, such as fires or floods, are neither malicious or nonmalicious.

Employees who cause network damage through ignorance, or because they were fooled by a skilled cracker, are considered nonmalicious network threats.


53. You are a developer for a large government service organization that uses the .NET platform as a standard for the development of Windows-based applications. The application you are designing has an extended initialization process when it is first executed. You must ensure that the application starts as quickly as possible the first time it runs. How would you prepare the application?

A. Precompile the application using the Visual Studio .NET, Native Image Generator (Ngen.exe).
B. Prepare your application for the client computers and use the JIT compiler.
C. Use the Global Assembly Cache tool (Gacutil.exe) to optimize the installation environment.
D. Use the .NET Framework Configuration tool (Mscorcfg.msc) to optimize the runtime environment.

>> !
Answer: A

This is the best way to optimize the initial execution of any deployed application so that the overhead in the common runtime engine is limited.

The JIT (just-in-time) compilation occurs at run-time, but takes considerable more time on execution than a application that has been precompiled.

The Global Assembly Cache tool allows you to view and manipulate the contents of the global assembly and download cache.

The .NET Framework Configuration tool allows for the management and configuration of assemblies in the Global Assembly Cache.


54. You are a developer for a company that uses Visual Studio .NET to supply shareware and freeware products for non-profit organizations. Some of these products are available on the Internet while others are available through mail order. You are developing a file sharing utility that will allow users from around the country to share their own materials. The application will display status information to the user in the form of string messages in a text box. You want the strings to be locally presented in the language of the user. You have prepared English, Spanish, French and Chinese resources. You want your application to be useable by others as well. How should you deploy the application?

A. Package a main assembly for source code and the default culture. Package satellite assemblies for the other cultures.
B. Package a different assembly for each culture.
C. Package a different executable file for each culture.
D. Package a main assembly for source code. Package satellite assemblies for each culture. Prepare other resources as they become available.

>> !
Answer: A

The resource files are compiled and then embedded in satellite assemblies, or assemblies that contain only the localized resources. The fallback resources would be present in the main assembly.

Though you could package a different assembly for each culture, it is far more effort than necessary and would be more difficult to implement.

You could package a different executable file for each culture but it is far more effort than necessary and would be more difficult to implement.

Packaging a main assembly for source code, then packaging satellite assemblies for each culture and then preparing other resources as they become available works in theory but it does not answer the question. Other cultures would have to wait until their resources have been deployed.


55. You are developing a project that will illustrate the functionality of structured exception handling. You will be using the project as a means of training new developers as they join the company. You enter the following code and are about to prepare documentation for the code:Public Sub TryExample() Try x /= y ' Causes a "Divide by Zero" error Catch ex As Exception When y = 0. MsgBox(ex.toString) Finally Beep() ' Beep after error processing. End TryEnd Sub When will the Beep() function execute?

A. The Beep() will never execute.
B. Only when an error occurs.
C. Only if there is no error.
D. Only if the error is resolved by the catch.
E. Each time the code is executed regardless of whether there is an error.

>> !
Answer: E

A Finally block is always executed when execution leaves any part of the Try statement.


56. You use Visual Studio .NET to develop a Windows-based application named Tamiskin Cooperative (TC). The TC has an Occupant class. The Occupant class is defined by the following code segment:

Namespace Tamiskin.Coop.Database
Public Class Occupant
Public Function GetOccupantName(OccupantID as Integer) as String

...
End Function ...
End Class
End Namespace

The client class is invoked as follows:
Public Class OccupantForm Inherits System.Windows.Forms.Form
Private Sub SetOccupantName(ByVal PostalCode As String)
Dim client as New Client()
txtOccupantName.Text = client.GetOccupantName(postalcode)
End Sub
End Class

When you try to build your project, you receive the following error message: "Type 'Occupant' is not defined." Which of the following solves the problem?

A. Modify the code to create an overloaded procedure.
B. Inherit and Override the function.
C. Declare the function as NotOverridable.
D. Declare the function as MustOverride.

>> !
Answer: A

Overloading is the creation of more than one procedure, instance constructor, or property in a class with the same name but different argument types. It would work in this case assuming the function handles both types internally.

Inheriting and Overriding the function would be a solution but may require a significant alteration to both applications.

Declaring the function as NotOverridable would accomplish the opposite of the desired effect.

Declaring the function as MustOverride is a possible solution but would require the client to have code to handle all situations.


57. You are in the process of developing a Windows-based application for a local legal services company. The application will process legal charges by passing an object array to a function. The function then uses a method to either update an existing record in the table or to add a new record. When you test your application, you frequently receive an exception of type InvalidCastException. What does the error represent?

A. The data is not correct for that column being updated.
B. You cannot pass an array of object variable types.
C. The destination variables have to be object type variables.
D. The variables should be passed as a collection instead.

>> !
Answer: A

Data not correct for that column being updated is the exception that is thrown for the invalid casting or explicit conversion of data from one variable to another, common on object data types as they can hold data of any type and the result is usually narrowing by going to any other type.

A passed array can contain object variables. The exception instead is thrown for the invalid casting or explicit conversion of data from one variable to another, common on object data types as they can hold data of any type and the result is usually narrowing by going to any other type.

Though requiring destination variables be object type variables would eliminate the error, it is possible to narrow an object variable to other data types. This is the exception that is thrown for the invalid casting or explicit conversion of data from one variable to another, common on object data types as they can hold data of any type and the result is usually narrowing by going to any other type.

Passing the variables as a collection is not going to solve the problem. This is the exception that is thrown for the invalid casting or explicit conversion of data from one variable to another, common on object data types as they can hold data of any type and the result is usually narrowing by going to any other type.


58. You use Visual Studio .NET to develop components for a systems consulting firm TOMORA Systems. You are developing a component that provides corporate-specific data that you plan to use in a number of different client applications. You would like to deploy the component with each of the client applications that you create in the future. Which type of setup project should you use to create a distribution package?

A. Use a Web Setup project.
B. Use the CAB setup project.
C. Use a basic Setup project.
D. Use the Merge Module setup project.

>> !
Answer: D

Merge module projects are used to package files or components that will be shared between multiple applications.

Creates a cabinet file for downloading to a legacy Web browser.

Builds an installer for a Windows-based application.

Builds an installer for a Web application.


59. You are done developing and testing your Windows application that uses Serviced Components and are ready to deploy it to all users throughout the company. You want the new application to be installed the next time the users log in to their work stations.

How should you deploy this application?

A. Create a Windows Installer application (.msi) and place it in the Active Directory Group Policies for electronic distribution to all users.
B. Create a Windows Installer application (.msi) and email it to the users with instructions for installation.
C. Create a custom executable (.exe) and email it to the users with instructions for installation.
D. Create a custom executable (.exe) and place it in the Active Directory Group Policies for electronic distribution to all users.

>> !
Answer: A

Creating a Windows Installer application and having Active Directory deploy it through Active Directory Group Policies is the only option that will ensure that all users will have the new Windows application installed the next time they log in. If set properly, the users will have no choice on the deployment, thus ensuring consistency for all users.


60. You are a developer for a large consulting firm. The company has used Visual Studio .NET to create an accounting application. The application has a variety of classes for each significant interaction. One of the classes supported is the VendorAccountClass. This class instantiates several classes from a COM component that was created previously using Visual Basic 6.0. Each COM component class includes a custom method named CloseObject that must be called before terminating references to the class. When you run the application the COM component appears to remain in memory even after the application terminates. You must ensure that the CloseObject method of each COM component class is called before VendorAccountsClass is terminated. How do you fix the problem?

A. Add the procedure Protected Overrides Finalize() to VendorAccountsClass. Add code to the procedure to call the CloseObject method of each COM component class.
B. Add code to the Terminate event of VendorAccountsClass to call the CloseObject method of each COM component class.
C. Execute a DoEvents command in the Finalize routine for the component.
D. Execute a directory entry remove command from the finalize routine of the component.

>> !
Answer: A

The Sub Finalize procedure in Visual Basic .NET destroys objects.The terminate event had been used in previous releases of Visual Basic. Initialize and terminate have now been replaced with Sub New and Sub Finalize.

DoEvents will execute all pending Windows events but won't help free resources if garbage collection is not pending.

Directory entry remove is used to remove objects from Active Directory.